#include "WindowFrame.h"
#include <QPainter>

WindowFrame::WindowFrame(FrameType type, QWidget* parent) :
	FrameAbstract(type, parent)
{
}

WindowFrame::~WindowFrame()
{
}

void WindowFrame::paintFrame(QPainter* painter)
{
	painter->setRenderHint(QPainter::SmoothPixmapTransform);

	int gradientHeight = height()>100 ? 100 : height();

	QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, gradientHeight));
	linearGrad.setColorAt(0, QColor(184,208,233));
	linearGrad.setColorAt(1, QColor(219,231,244));
	painter->setPen(QColor(184,208,233));
	painter->setBrush(QBrush(linearGrad));

	if(_type == FrameLeft){
		painter->fillRect(0,0,width(),height(),QColor(184,208,233));

		painter->setPen(QColor(184,208,233));
		painter->drawRect(0,0,width(),gradientHeight);

		painter->setPen(QColor(52,52,52));
		painter->drawLine(0,0,0,height());

		painter->setPen(QColor(255,255,255));
		painter->drawLine(1,0,1,height());
	}
	if(_type == FrameRight){
		painter->fillRect(0,0,width(),height(),QColor(184,208,233));

		painter->setPen(QColor(184,208,233));
		painter->drawRect(0,0,width(),gradientHeight);

		painter->setPen(QColor(52,52,52));
		painter->drawLine(width()-1,0,width()-1,height()-1);

		painter->setPen(QColor(105,217,255));
		painter->drawLine(width()-2,0,width()-2,height());
	}
	if(_type == FrameBottom){
		painter->setPen(QColor(52,52,52));
		painter->fillRect(0,0,width(),height(),QColor(185,209,234));
		painter->drawLine(0,height()-1,width()-1,height()-1);
		painter->drawLine(0,0,0,height());
		painter->drawLine(width()-1,0,width()-1,height());

		painter->setPen(QColor(255,255,255));
		painter->drawLine(1,0,1,height()-2);

		painter->setPen(QColor(105,217,255));
		painter->drawLine(width()-2,0,width()-2,height()-2);
		painter->drawLine(2,height()-2,width()-2,height()-2);
	}
}
